<?php

namespace app\admin\model;

use think\Model;
use think\Db;

class Type extends Model
{
    // 表名
    protected $name = 'type';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [

    ];
    
    public static $info_kind = array(
        'information' => '信息类',
        'mission' => '任务类',
        'info_mission' => '任务信息类'
    );
    public static $life_kind = array(
        'service_bbs' => '论坛',
        'service_story' => '餐饮故事',
        'service_voice' => '餐饮声音',
        'service_information' => '前沿资讯'
    );
    
    public function getType($category = null, $pid = null){
        $where = array();
        $where['is_delete'] = 0;
        if($category) {
            $where['category'] = array('eq', $category);
        }
        if($pid) {
            $where['p_id'] = array('eq', $pid);
        }
        $type = Db::name('type')->field('type_id, type_name')->where($where)->select();
        $return = array();
        foreach ($type as $k=>$v) {
            $return[$v['type_id']] = $v['type_name'];
        }
        return $return;
    }
    
    







}
